<template>
  <view class="g-content">
    <uni-card
      class="card-course"
      :title="item['课程名']"
      :is-shadow="true"
      :note="item['上课地点']"
      v-for="item in list"
      :id="item['课程号']"
    >
      <view>上课时间：<span>{{ item['上课时间'] }}</span></view>
      <view>老师：<span>{{ item['老师'] }}</span></view>
      <view>联系方式： <span>{{ item['老师联系方式'] }}</span></view>
    </uni-card>
    <div style="height: 120rpx;"></div>
    <hans-tabber :list="tab" class="g-tabbar" style="position:fixed;bottom:0;width:100%;left:0;right:0;" :current="0"></hans-tabber>
  </view>
</template>

<script>
  import Student from '../../../api/Student.js'
  export default {
  	data() {
  		return {
        uid: this.$store.state.token.id,
  			list: [],
        tab: [
          {
          	"text":"学期课程",
          	"pagePath":"today",
          	"iconPath":"../../../static/icon/mail.png",
          	"selectedIconPath":"../../../static/icon/mail.png"
          },
          {
          	"text":"签到信息",
          	"pagePath":"get_sign",
          	"iconPath":"../../../static/icon/task.png",
          	"selectedIconPath":"../../../static/icon/task.png"
          }
        ]
  		}
  	},
    onInit() {
      this.uid = this.$store.state.token.id;
    },
  	onLoad() {      
      this._initList();
  	},
  	methods: {
      toDetail(){
        uni.navigateTo({
          url: 'detail',
          success: ()=>{
            console.log('成功');
          },
          fail: (e) => {
            console.log('失败',e);
          }
        });
      },
      async _initList(){
        this.Test.log('学生-学期课程',this.uid);
        const rm = (await Student.courses(this.uid));
        this.Test.log('学生-学期课程',rm);
        if(rm[1]['statusCode'] == '200'){
          if(rm[1].data == [] || rm[1].data == ''){
            this.Toast.show('无课程');
            this.list = [];
            return;
          }
          this.list = rm[1].data;
          //this.Toast.show('数据已加载');
        }
      }
  	} 
  }
</script>

<style>
  .card-course {
    height: 400rpx;
    width: 600rpx;
  }
</style>
